# Contributor: Yohann DANELLO <yohann.danello@crans.org>
# Maintainer: Yohann DANELLO <yohann.danello@crans.org>
pkgname=libsrt
pkgver=1.5.3
pkgrel=0
pkgdesc="Secure Reliable Transport (SRT)"
options="!check" # TestMuxer.IPv4_and_IPv6 fail when setting up IPv6
url="https://www.srtalliance.org/"
arch="all"
license="MPL-2.0"
makedepends="cmake openssl-dev>3 linux-headers samurai"
checkdepends="gtest-dev"
subpackages="$pkgname-progs $pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/Haivision/srt/archive/v$pkgver.tar.gz"
builddir="$srcdir/srt-$pkgver"

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja -Wno-dev \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DUSE_ENCLIB=openssl-evp \
		-DENABLE_UNITTESTS="$(want_check && echo ON || echo OFF)" \
		-DENABLE_TESTING="$(want_check && echo ON || echo OFF)" \
		-DENABLE_STATIC=OFF \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	# Broken tests
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

progs() {
	pkgdesc="Tools for working with SRT"
	depends=""
	amove usr/bin
}

sha512sums="
5b576d6fd325515e05074e4568e3b65d1ae265e3e971db6e6242e5138243fc1594df1e3a7d90962385dac38abc34c4c4b0a567439050f8c0ff818b3b3d497efc  libsrt-1.5.3.tar.gz
"
